﻿using MiniFox.Utility;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Wechat.Core
{
    /// <summary>
    /// 
    /// </summary>
    public class WechatException : Exception
    {
        private int _code;
        private string _message;
        private object _requestData;
        private string _requestUri;

        /// <summary>
        /// 
        /// </summary>
        /// <param name="errorCode"></param>
        /// <param name="errorMessage"></param>
        public WechatException(int errorCode, string errorMessage)
        {
            this._code = errorCode;
            this._message = errorMessage;
        }

        /// <summary>
        /// 
        /// </summary>
        public int ErrorCode
        {
            get
            {
                return this._code;
            }
        }
        /// <summary>
        /// 
        /// </summary>
        public string RequestUri
        {
            get { return _requestUri; }
            set
            {
                _requestUri = value;
                this.Data.Add("RequestUri", _requestUri);
            }
        }
        /// <summary>
        /// 
        /// </summary>
        public object RequestData
        {
            get { return _requestData; }
            set
            {
                _requestData = value;
                this.Data.Add("RequestData", _requestData == null ? string.Empty : _requestData.ToJsonString());
            }
        }
        /// <summary>
        /// 
        /// </summary>
        public override string Message
        {
            get
            {
                return "[" + _code + "]" + _message;
            }
        }
    }
}
